package com.bbx.taxi.client.Listener;




import org.json.JSONObject;

import com.bbx.api.sdk.Config;
import com.bbx.api.sdk.model.passanger.Return.Jmsg.Msgs;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.Bean.Message.Publisher;
import com.google.gson.JsonObject;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * 
 */
public class MsgBroadcastReceiver extends BroadcastReceiver {
	public final static String TAG = "CLIENT_MSG"+Config.APP_STYPE+Config.getInstance().APP_PLATFORM;
	public final static String MSG_JSON="json";
	public final static String MSG_TYPE="type";
	public final static String MSG_DATA="jmsg_data";
	@Override
	public void onReceive(final Context context, Intent intent) {
		 try {
	            String action = intent.getAction();
	            String json = intent.getStringExtra(MSG_JSON);
	            int type = intent.getIntExtra(MSG_TYPE, -1);
	            String jmsg_data = intent.getStringExtra(MSG_DATA);
	            JSONObject jb=null;
	            if(json!=null){
	                jb=new JSONObject(json);
	            }
	    		Msgs.Data msgs_data =null;
	    		if(jmsg_data!=null){
	    			try{
	    				msgs_data=(Msgs.Data) new JsonBuild().getData(
	    	    				Msgs.Data.class, jmsg_data.toString());
	    			}catch(Exception e){}
	    		}
	            Publisher.getInstance().publish(type, jb,msgs_data);
	        	
		 }catch(Exception e){
		 }
	}

}
